package stores

import (
	"jvm/nzpJvm/instructions/base"
	"jvm/nzpJvm/runtime_area"
)

// 将操作数栈中一个float存入局部变量表指定索引位置
type FSTORE struct{ base.Index8Instruction }
type FSTORE_0 struct{ base.NoOperandsInstruction }
type FSTORE_1 struct{ base.NoOperandsInstruction }
type FSTORE_2 struct{ base.NoOperandsInstruction }
type FSTORE_3 struct{ base.NoOperandsInstruction }

func (self *FSTORE) Execute(frame *runtime_area.Frame) {
	_fstore(frame, self.Index)
}
func (self *FSTORE_0) Execute(frame *runtime_area.Frame) {
	_fstore(frame, 0)
}
func (self *FSTORE_1) Execute(frame *runtime_area.Frame) {
	_fstore(frame, 1)
}
func (self *FSTORE_2) Execute(frame *runtime_area.Frame) {
	_fstore(frame, 2)
}
func (self *FSTORE_3) Execute(frame *runtime_area.Frame) {
	_fstore(frame, 3)
}
func _fstore(frame *runtime_area.Frame, index uint) {
	// 从栈帧的操作数栈中出一个float值，
	float := frame.OperandStack().PopFloat()
	// 保存到本地变量表中
	frame.LocalVars().SetFloat(index,float)
}

